﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.Text;
using System.Web;
using DataModel;

namespace ApplicationServer
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "ControllerService" in code, svc and config file together.
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
    public class ControllerService : IControllerService
    {
        

        public string GetMyData()
        {
            K8055Data k8055Data = TicketManager.Get(HttpContext.Current.Application);
            string s = k8055Data.Output.ToString();

            return s;
        }

        


        byte[] Encrypt(string plain)
        {
            
            // define the byte array that we will use
            // as plaintext
            byte[] x_plaintext = Encoding.Default.GetBytes(plain);

            // Create an instance of the algorithm and generate some keys
            ElGamal x_alg = ElgmalKeyDistro.GetElgamal();
        
            // extract and print the xml string (this will cause
            // a new key pair to be generated)
            string x_xml_string = x_alg.ToXmlString(true);
            Console.WriteLine("\n{0}\n", x_xml_string);

            // Test the basic encryption support
            ElGamal x_encrypt_alg = new ElGamalManaged();
            // set the keys - note that we export without the
            // private parameters since we are encrypting data
            x_encrypt_alg.FromXmlString(x_alg.ToXmlString(false));
            byte[] x_ciphertext = x_alg.EncryptData(x_plaintext);

         
          return  x_ciphertext;

        }
    }
}
